﻿<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>银行交易清单列表信息</title>
    <link rel="stylesheet" type="text/css" href="../Content/Css/OperaMasksUI/default/om-all.css" />
    <link rel="stylesheet" type="text/css" href="../Content/Css/list.css" />
    <script type="text/javascript" src="../Scripts/jquery.1.6.3.min.js"></script>
    <script type="text/javascript" src="../Scripts/json2.js"></script>
    <script type="text/javascript" src="../Scripts/common.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/operamasks-ui.min.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/jquery.form.js"></script>
    <script type="text/javascript" src="../Scripts/OperaMasksUI/Plugin/om-yj-container.js"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/jquery.artDialog.js?skin=default"></script>
    <script type="text/javascript" src="../Scripts/Plugin/artDialog4.1.7/plugins/iframeTools.js"></script>
    <script type="text/javascript" src="../Scripts/banBackSpace.js"></script>
    <script type="text/javascript">
        var listGrid, colData, searchPanel, defaultSort, defaultWhere, currentUID, genRenderInput, UID;
        var showSearchPanel, goOn = true;

        $(document).ready(function () {
            var element = $('body').omBorderLayout({
                fit: true,
                spacing: 0,
                panels: [
                {
                    id: "center-panel",
                    header: false,
                    title: "中间模块",
                    region: "center"
                },
                {
                    id: "south-panel",
                    region: "south",
                    header: false,
                    resizable: false,
                    collapsible: false,
                    height: 50
                }
                ]
            });
            UID = art.dialog.data('UID');
            currentUID = art.dialog.data('currentUID');
            showSearchPanel();
            colData = [
                { header: '流水号/发票号码', name: 'OrderNo', width: 200, align: 'left' },
                { header: '报关单号/发票抬头', name: 'DeclareNo', width: 200, align: 'left' },
                { header: '客户', name: 'CustomerName', width: 200, align: 'left' },
                { header: '金额', name: 'Amount', width: 80, align: 'center' },
                { header: '剩余金额', name: 'AmountRemain', width: 80, align: 'center' },
                { header: '交易金额', name: 'AmountGet', width: 100, align: 'left', renderer: genRenderInput }
            ];
            defaultSort = { sortby: 'UID', sortdir: 'ASC' };
            defaultWhere = { where: '1=1'};
            listGrid = $('#listgrid').omGrid({
                width: '100%',
                height: 400,
                singleSelect: false,
                limit: 50,
                extraData: $.extend(defaultWhere, defaultSort),
                dataSource: '../Handler/grid.ashx?view=vIncomeGet',
                colModel: colData
            });
        });

        genRenderInput = function (colValue, rowData, rowIndex) {
            return '<input style="width:100%" type="text" id=AmountGet' + rowIndex + ' value=' + rowData.AmountRemain + ' />';
        }

        showSearchPanel = function () {
            $('#button-confirm').click(function () {
                if (listGrid[0].rows.length > 0) {
                    var selectRow = listGrid.omGrid("getSelections", true);
                    var selectRowIndex = listGrid.omGrid("getSelections");
                    var errorInfo = '';
                    if (selectRow.length > 0) {
                        var tempuid = '', tempAmountGet = '', tempType = '';
                        $.each(selectRow, function (index, value) {
                            var tempIndex = selectRowIndex[index];
                            var tempGet = $("input[id=AmountGet" + tempIndex + "]", listGrid[0].rows[tempIndex]).val();
                            if (!isNaN(tempGet)) {
                                tempuid += value.UID + ',';
                                tempType += value.Type + ',';
                                tempAmountGet += tempGet + ',';
                            }
                            else {
                                errorInfo = '选中的第' + (tempIndex+1) + '行数据请输入数字';
                                return true;
                            }
                        });
                        if (errorInfo == '') {
                            $.omMessageBox.confirm({
                                title: '确认',
                                content: '确定要收款吗？',
                                onClose: function (v) {
                                    if (v) {
                                        $.ajax({
                                            cache: false, async: false,
                                            url: '../handler/ajax.ashx?type=AjaxSystem&method=GetIncome',
                                            dataType: 'json', type: 'post',
                                            data: { UID: UID, SELECTUID: tempuid.substring(0, tempuid.length - 1), SELECTTYPE: tempType.substring(0, tempType.length - 1), SELECTGET: tempAmountGet.substring(0, tempAmountGet.length - 1), USERID: currentUID },
                                            beforeSend: function () {
                                                $.omMessageBox.waiting({
                                                    title: '请等待',
                                                    content: '系统正在提交信息,请稍后...'
                                                });
                                            },
                                            complete: function () {
                                                $.omMessageBox.waiting("close");
                                            },
                                            success: function (data) {
                                                if (data.IsError) {
                                                    $.omMessageBox.alert({
                                                        content: '错误：' + data.Message
                                                    });
                                                }
                                                else {
                                                    $.omMessageBox.alert({
                                                        content: '收款成功',
                                                        onClose: function () {
                                                            art.dialog.close();
                                                        }
                                                    });
                                                }
                                            },
                                            error: function (result) {
                                                $.omMessageBox.alert({
                                                    content: '发现系统错误,请重新登录<BR>错误码：' + result.status
                                                });
                                            }
                                        });
                                    }
                                }
                            });
                        }
                        else {
                            $.omMessageBox.alert({
                                content: errorInfo
                            });
                        }
                    }
                    else {
                        $.omMessageBox.alert({
                            content: '至少选取一条要收款的数据'
                        });
                    }
                }
            });
        };
    </script>
</head>
<body>
    <div id="center-panel">
        <table id="listgrid"></table>
    </div>
    <div id="south-panel">
        <table style="margin-top:5px; margin-left:20px;">
            <tr>
                <td>
                    <input id="button-confirm" type="button" class="btnCss" value="确    定" />
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
